Files
kios-webapp/astro/src/pages/posts/[id].astro
Max Schmidt d30d3e61b9 lool
Signed-off-by: Max Schmidt <max.schmidt@outlook.de>
2023-05-17 11:56:36 +02:00

32 lines
731 B
Plaintext

---
import Layout from "../../layouts/Layout.astro";
import Content from "../../components/Content.astro";
import type { Post } from "../../types";
import { getPost, getPosts } from "../../utils/payload";
export async function getStaticPaths() {
const posts = await getPosts();
const paths = posts.map((post: Post) => ({
params: { id: post.id },
}));
return paths;
}
const { id } = Astro.params;
const post = id && (await getPost(id));
---
{
post ? (
<Layout title={`Astroad | ${post.title!}`}>
<div class="space-y-3 my-3">
<a href="/">BACK</a>
<h1>{post.title}</h1>
{post.content && <Content content={post.content} />}
</div>
</Layout>
) : (
<div>404</div>
)
}